package com.jims.master.modules.api.emr.web;


import com.jims.master.common.web.BaseController;

import com.jims.master.common.web.impl.BaseDto;
import com.jims.master.modules.doctor.service.HisDiagnosisService;
import com.jims.master.modules.doctor.service.PatMasterIndexService;
import com.jims.master.modules.finance.service.InpBillDetailService;
import com.jims.master.modules.operation.entity.OperationMaster;
import com.jims.master.modules.operation.service.OperationMasterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Created by zhao on 2015/12/16.
 * 病人基本信息
 * @author 赵宁
 */
@RestController
@RequestMapping(value = "emr/patient")
public class PatListController extends BaseController {
    @Autowired
    private PatMasterIndexService patMasterIndexService;
    @Autowired
    private HisDiagnosisService hisDiagnosisService;
    @Autowired
    private OperationMasterService operationMasterService;
    @Autowired
    private InpBillDetailService inpBillDetailService;
    /**
     * 获取用户的病人信息(刷新病人列表)
     * @param map
     * @return List<BaseDto>
     * @author 赵宁
     */
    @RequestMapping(value = "singlePatient")
    public  List<BaseDto> singlePatient(@RequestBody Map<String, Object> map){
        BaseDto dto=new BaseDto();
        dto.putAll(map);
        List<BaseDto> list= patMasterIndexService.findPatList(dto);
        return list;
    }

    /**
     * 刷新病人列表--获取病人住院信息
     * @param map
     * @return
     * @author 赵宁
     */
    @RequestMapping(value = "patVisit")
    public  List<BaseDto> patVisit(@RequestBody Map<String, Object> map){
        BaseDto dto=new BaseDto();
        dto.putAll(map);
        List<BaseDto> list= patMasterIndexService.findPatVisitList(dto);
        return list;
    }

    /**
     * 同步病历--更新病人基本信息
     * @return
     */
    @RequestMapping(value = "updateBasicInfo")
   public List<BaseDto> updatePatientBaiscInfo(@RequestBody Map<String, Object> map){
       String visitId=(String)map.get("visitId");
       List<BaseDto> list =patMasterIndexService.updateBasicInfo(visitId);
        return list;
   }
    /**
     * 同步病历--更新病人住院信息
     * @param map
     * @return
     * @author 赵宁
     */
    @RequestMapping(value = "updatePatInfo")
    public  List<BaseDto> updatePatInfo(@RequestBody Map<String, Object> map){
        String visitId = (String)map.get("visitId");
        List<BaseDto> list= patMasterIndexService.updatePatInfo(visitId);
        return list;
    }

    /**
     * 同步病历--更新病人诊断信息
     * @param map
     * @return
     * @author 赵宁
     */
    @RequestMapping(value = "findDiagnosisEmr")
    public List<BaseDto> findDiagnosisEmr(@RequestBody Map<String, Object> map){
        String visitId=(String)map.get("visitId");
        String patientId=(String)map.get("patientId");
        List<BaseDto> list=hisDiagnosisService.findDiagnosisEmr(patientId,visitId);
        return list;
    }

    /**
     * 同步病历--更新病人手术信息
     * @param map
     * @return
     * @author 赵宁
     */
    @RequestMapping(value = "findOperatorEmr")
    public List<BaseDto> findOperatorEmr(@RequestBody Map<String, Object> map){
        String visitId=(String)map.get("visitId");
        List<BaseDto> list=operationMasterService.findOperatorInfoEmr(visitId);
        return list;
    }

    /**
     * 同步病历--更新病人费用信息
     * @param map
     * @return
     * @author 赵宁
     */
    @RequestMapping(value = "findMedicalCosts")
   public List<BaseDto> findMedicalCosts(@RequestBody Map<String, Object> map){
       String patientId=(String)map.get("patientId");
       String visitId=(String)map.get("visitId");
       List<BaseDto> list=inpBillDetailService.findMrCosts(visitId,patientId);
       return list;

   }
}
